home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / Qpopper / pop_rpop.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-01  |  2.3 KB  |  77 lines

  1. /*
  2.  * Copyright (c) 1989 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef lint
  8. static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
  9. #endif
  10.  
  11. #include <stdio.h>
  12. #include <sys/types.h>
  13. #ifdef SYSV
  14. #include <string.h>
  15. #else
  16. #include <strings.h>
  17. #endif
  18. #include <pwd.h>
  19. #include <netinet/in.h> /* For IPPORT_RESERVED */
  20. #include "popper.h"
  21.  
  22. /*
  23.  * Use /etc/hosts.equiv and the users .rhost file to validate the user.
  24.  */
  25. int pop_rpop (p)
  26.      POP     *   p;
  27. {
  28.   struct passwd  *   pw;
  29.  
  30.     if (p->ipport >= IPPORT_RESERVED || p->ipport < IPPORT_RESERVED/2)  {
  31.       pop_log(p,POP_PRIORITY,
  32.           "RPOP command from %s (%s) on illegal port.",p->client,p->ipaddr);
  33.         return (pop_msg(p,POP_FAILURE,
  34.             "Permission denied.",p->user));
  35.     }
  36.     if (ruserok(p->client, 0, p->pop_parm[1], p->user) != 0)
  37.         return (pop_msg(p,POP_FAILURE,
  38.             "Permission denied.",p->user));
  39. #ifdef NONAUTHFILE
  40.     if (checknonauthfile(p->user) != 0)
  41.         return (pop_msg(p,POP_FAILURE,
  42.             "Permission denied.",p->user));
  43. #endif
  44. #ifdef AUTHFILE
  45.     if (checkauthfile(p->user) != 0)
  46.         return (pop_msg(p,POP_FAILURE,
  47.             "Permission denied.",p->user));
  48. #endif
  49.  
  50.     if ((pw = getpwnam(p->user)) == NULL)  /* "Can't happen" */
  51.         return (pop_msg(p,POP_FAILURE,
  52.             "Permission denied.",p->user));
  53.  
  54.     if (pw->pw_uid <= BLOCK_UID)
  55.     return (pop_msg(p,POP_FAILURE, "Permission denied", p->user));
  56.  
  57.     /*  Build the name of the user's maildrop */
  58.     if (genpath(p) < 0)
  59.     return(pop_msg(p, POP_FAILURE, "Unable to create temporary drop name"));
  60.  
  61.     /*  Make a temporary copy of the user's maildrop */
  62.     /*    and set the group and user id */
  63.     if (pop_dropcopy(p, pw) != POP_SUCCESS) return (POP_FAILURE);
  64.  
  65.     /*  Get information about the maildrop */
  66.     /* if (pop_dropinfo(p) != POP_SUCCESS) return(POP_FAILURE); */
  67.  
  68.     /*  Initialize the last-message-accessed number */
  69.     p->last_msg = 0;
  70.  
  71.     /*  Authorization completed successfully */
  72.     return (pop_msg (p,POP_SUCCESS,
  73.         "%s has %d message(s) (%d octets).",
  74.             p->user,p->msg_count,p->drop_size));
  75. }
  76.  
  77.